package com.retail.system.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.system.entity.request.AdminUpgradeConfigRequest;
import com.retail.system.entity.vo.AdminUpgradeConfigVo;
import com.retail.system.service.AdminUpgradeConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 团队长晋升配置1 API
* @author Administrator
*/
@Api(tags = "区域合伙人晋升配置1 API")
@RestController
@RequestMapping("/adminUpgradeConfig")
public class AdminUpgradeConfigController extends AbstractCommonController<AdminUpgradeConfigService, AdminUpgradeConfigRequest, AdminUpgradeConfigVo>{

    @Autowired
    private AdminUpgradeConfigService adminUpgradeConfigService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(adminUpgradeConfigService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存区域合伙人晋升配置1")
    public Result<Integer> save(@RequestBody AdminUpgradeConfigRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(adminUpgradeConfigService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新区域合伙人晋升配置1")
    public Result<Integer> update(@RequestBody AdminUpgradeConfigRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(adminUpgradeConfigService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("区域合伙人晋升配置1-查询")
    public Result<List<AdminUpgradeConfigVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(adminUpgradeConfigService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("区域合伙人晋升配置1-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(adminUpgradeConfigService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("区域合伙人晋升配置1-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<AdminUpgradeConfigRequest> req) {
        return super.page(adminUpgradeConfigService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除区域合伙人晋升配置1")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(adminUpgradeConfigService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除区域合伙人晋升配置1")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(adminUpgradeConfigService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
